<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .active{
            color: red;
        }
    </style>
</head>
<body>
    <script src="/js/vue.js"></script>
    <div id="root">
        <ul v-for="(item,index) in movies" :key="item">
            <li :class="{active:currentIndex  === index}" @click="liClick(index)">{{item}}</li>
        </ul>
    </div>
    <script>
        const vm = new Vue({
            el:'#root',
            data(){
                return{
                    currentIndex:'',
                    movies:["星际穿越","飞驰人生","2001太空漫游","长津湖","迪迦奥特曼"],
                    
                }
            },
            methods: {
                liClick(index){
                    console.log(this.currentIndex,index)
                    this.currentIndex = index;
                }
            },
        })
    </script>
</body>
</html>